import log4js from "log4js"

log4js.configure({
  appenders: {
    console: { type: "console" },

    dailyfile: {
      type: "dateFile",
      filename: "logs/app/main",
      pattern: "yyyy-MM-dd.log",
      alwaysIncludePattern: true,

      numBackups: 2,

      layout: {
        type: "pattern",
        pattern: "[%d{yyyy-MM-dd hh:mm:ss}] [%p] %m",
      },
    },

    biliTraceFile: {
      type: "dateFile",
      filename: "logs/bili/trace/file",
      pattern: "yyyy-MM-dd.log",
      alwaysIncludePattern: true,
      layout: {
        type: "pattern",
        pattern: "[%d{yyyy-MM-dd hh:mm:ss}] [%p] %m",
      },
    },

    biliSuccessfile: {
      type: "dateFile",
      filename: "logs/bili/success/file",
      pattern: "yyyy-MM-dd.log",
      alwaysIncludePattern: true,
      layout: {
        type: "pattern",
        pattern: "[%d{yyyy-MM-dd hh:mm:ss}] [%p] %m",
      },
    },
  },

  categories: {
    biliTrace: {
      appenders: ["biliTraceFile", "console"],
      level: "trace",
    },

    biliSuccess: {
      appenders: ["biliSuccessfile", "console"],
      level: "fatal",
    },

    default: { appenders: ["dailyfile", "console"], level: "trace" },
  },
})

export const logger = log4js.getLogger()

export const biliTrace = log4js.getLogger("biliTrace")

export const biliSuccess = log4js.getLogger("biliSuccess")
